package com.sjzd.server.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 *  统一响应返回类
 * @author ZFQ
 * @date 2021/2/21
 */
@ApiModel(value="RespBean对象", description="统一响应返回类")
public class RespBean {
    @ApiModelProperty(value = "响应状态码")
    private Integer statusCode;

    @ApiModelProperty(value = "响应信息")
    private String message;

    @ApiModelProperty(value = "响应返回对象")
    private Object obj;

    private RespBean(Integer statusCode, String message, Object obj) {
        this.statusCode = statusCode;
        this.message = message;
        this.obj = obj;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getObj() {
        return obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }

    @Override
    public String toString() {
        return "RespBean{" +
                "statusCode=" + statusCode +
                ", message='" + message + '\'' +
                ", obj=" + obj +
                '}';
    }


    public static RespBean success(String message) {
        return new RespBean(200, message, null);
    }

    public static RespBean success(String message, Object obj) {
        return new RespBean(200, message, obj);
    }

    public static RespBean error(String message) {
        return new RespBean(500, message, null);
    }

    public static RespBean error(String message, Object obj) {
        return new RespBean(500, message, obj);
    }
}